version: '3.8'

services:
  backend:
    build: 
      context: ./backend
      target: prod
    container_name: gurren-backend
    # ports:
    #   - 5000:5000
    secrets:
      - recaptcha_secret
    labels:
      - traefik.enable=true
      - traefik.http.services.gurren-backend.loadbalancer.server.port=5000      
      - traefik.http.routers.gurren-backend.rule=PathPrefix(`/ws/`)
      - traefik.http.routers.gurren-backend.tls=true
  ui:
    container_name: gurren-ui
    build: 
      context: ./ui
      target: prod
    command: ["vite", "preview", "--port", "8008", "--host"]
    stop_signal: SIGKILL
    # ports
    #   - 8008:8008
    labels:
      - traefik.enable=true
      - traefik.http.routers.gurren-ui.rule=PathPrefix(`/`)
      - traefik.http.services.gurren-ui.loadbalancer.server.port=8008
      - traefik.http.routers.gurren-ui.tls=true
      - traefik.http.routers.gurren-ui.tls.certresolver=letsEncrypt
      - traefik.http.routers.gurren-ui.tls.domains[0].main=vps1.docc.ru
  traefik:
    container_name: traefik
    image: traefik:latest
    stop_signal: SIGKILL
    ports:
      - 80:80
      - 443:443
      - 8080:8080  # The Web UI (enabled by --api.insecure=true)
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /etc/localtime:/etc/localtime:ro    
      - ./traefik/traefik.prod.yml:/traefik.yml:ro
      - ~/gurren/traefik.acme.json:/acme.json     
    
secrets:
  recaptcha_secret:
    file: ~/gurren/recaptcha_secret.txt
